# -*-coding:utf-8-*-
import sys
from sqlalchemy import Column, String, Text, Date
from sqlalchemy.orm import relationship
from props.sql_connect import Base

reload(sys)

sys.setdefaultencoding('utf-8')


class book(Base):
    __tablename__ = 'doe_book'
    book_id = Column(String(20), primary_key=True)
    book_name = Column(String(256))  # 书名
    author = Column(String(256))  # 作者
    publisher = Column(String(256))  # 出版社
    pre_name = Column(String(256))  # 原作名
    translator = Column(String(156))  # 译者
    date = Column(String(32))  # 出版时间
    pages = Column(String(32))  # 页数
    price = Column(String(32))  # 价格
    ISBN = Column(String(32))  # ISBN
    star = Column((String(32)))  # 评分
    last_update = Column(Date)  # 上次更新时间
    image_url = Column(String(512))  # 封面url

    content_des = Column(Text)
    author_des = Column(Text)
    tag = Column(Text)

    # ref_tag = relationship('book_tag')

    def __init__(self, bookID):
        self.book_id = bookID

    # toString()
    def __repr__(self):
        return '**BOOK***' + self.book_name
